﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;

namespace CardLogistics.Web.Controls
{
    public partial class WebUserControl_AppInfo : System.Web.UI.UserControl
    {
        /// <summary>
        /// 信息ID
        /// </summary>
        public string InfoID
        {
            get;
            set;
        }
        /// <summary>
        /// 用户ID
        /// </summary>
        public string UserID
        {
            get;
            set;
        }
        /// <summary>
        /// 当前审批内容
        /// </summary>
        public string ApproName
        {
            get;
            set;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                CreateAppInfo();
        }
        /// <summary>
        /// 加载审批信息
        /// </summary>
        private void CreateAppInfo()
        {
            StringBuilder sbStr = new StringBuilder();
            DataTable dt = CardLogistics.DAL.DbHelperSQL.GetQueryResult(" SELECT * FROM V_APPROVALINFO WHERE INFOID='" + InfoID + "' order by APPDATE desc ");
            if (dt != null && dt.Rows.Count > 0)
            {
                sbStr.Append("<table class='theForm' width='99%'  border='0' cellspacing='0' cellpadding='0'>");
                foreach (DataRow dr in dt.Rows)
                {
                    sbStr.Append("<tr><td  style='line-height:25px;height:40px; '>");
                    sbStr.Append("<b>" + dr["userfullname"].ToString() + "</b>");
                    if (dr["statusName"].ToString()=="未审批")
                    {
                        sbStr.Append("&nbsp;&nbsp;待审批");
                        if (UserID == dr["userid"].ToString())
                            sbStr.Append("&nbsp;&nbsp;<img src='../../../images/ApplyApprove.gif' style='margin-right:2px;margin-bottom:-4px' onclick=\"AppchkDetail('" + ApproName + "','" + InfoID + "');location.href='#';\" />");
                    }
                    else
                    {
                        sbStr.Append("[<b>" + dr["statusName"].ToString() + "</b>]&nbsp;&nbsp;审批意见[<font color='red'>" + dr["appcontent"].ToString() + "</font>]&nbsp;&nbsp;" + dr["appdate"].ToString());
                    }
                    sbStr.Append("</td></tr>");
                }
                sbStr.Append("</table>");
            }   
            d_AppInfo.InnerHtml = sbStr.ToString();
        }
    }
}